package com.andrew.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.andrew.service.OrderService;
import com.andrew.service.impl.OrderServiceImpl;

public class AlterSingleOrderItemServlet extends HttpServlet {
	private OrderService orderService=new OrderServiceImpl();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		//设置编码
		req.setCharacterEncoding("UTF-8");
		resp.setContentType("text/html;charset=UTF-8");
		//OrderId, BookId, NewQuantity
		String orderId=req.getParameter("OrderId");
		int bookId=Integer.parseInt(req.getParameter("BookId"));
		int newQuantity=Integer.parseInt(req.getParameter("NewQuantity"));
		
		//更新订单数量与总价
		orderService.updateOrderDetail(orderId, bookId, newQuantity, req, resp);
		
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		this.doGet(req, resp);
	}
}
